/*
 *   SlimPlayer Copyright (c) 2006 Koelec
 *
 *   This file is part of SlimPlayer plugin for SageTv.
 *
 *   Slimplayer is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   Slimplayer is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with SoftSqueeze; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */
package nl.cmkprojects.sage.slimplayer;

import java.lang.reflect.InvocationTargetException;

import org.apache.log4j.Logger;

import sage.SageTV;

public class SagePropertyHelper
{
  private static Logger logger = Logger.getLogger(SagePropertyHelper.class);
  
  public static String getSageTvProperty(String name, String def)
  {
	
    String result = def;
    if (Boolean.getBoolean("slimplayer.standalone") == false)
    {
      try
      {
        Object o = SageTV.api("GetProperty", new Object[]
        { name, def });
        result = (String)o;
      } catch (InvocationTargetException e)
      {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
    logger.debug("getSageTVProperty(name=" + name + ", def=" + def + ") returns=" + result);
    return result;
  }

  public static void setSageTvProperty(String name, String value)
  {
	logger.debug("setSageTVProperty(name=" + name + ", val=" + value);
    if (Boolean.getBoolean("slimplayer.standalone") == false)
    {
      try
      {
        SageTV.api("SetProperty", new Object[]
        { name, value });
      } catch (InvocationTargetException e)
      {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }

}
